<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Test</title>
    <script src="/static/js/jquery-3.4.1.min.js"></script>
    <script src="/static/js/toupiao.js"></script>
</head>
<body>
<div class="toupiao" title="投票">
    <h1>
        测试投票
    </h1>
    <button type="button">a</button>
    <button type="button">b</button>
    <button type="button">c</button>
    <p id="toupiaoResult"></p>
</div>

<div title="报名">
    <h1>报名</h1>
    <label for="BaomingName">参赛选手</label>
    <input id="BaomingName" type="text">
    <button id="BaomingButton" type="button">报名！</button>
</div>

<div title="抽奖">
    <h1>抽奖</h1>

    <p>其他参与抽奖：总裁，总裁小姨子，隔壁车间的老王，秘密嘉宾</p>
    <button id="ChouJiangButton" type="button">好运来！</button>
</div>

<div title="验证码">
    <h1>2秒验证码</h1>
    <button id="getYZM" type="button">get</button>
    <input type="text" id="YZM">
    <button id="checkYZM" type="button">check</button>
</div>

<div>
    <h1>并集</h1>
    <div>
        <form id="ilikeA">
            您喜欢的水果？<br /><br />
            <label><input name="Fruit" type="checkbox" value="a" />a </label>
            <label><input name="Fruit" type="checkbox" value="b" />b </label>
            <label><input name="Fruit" type="checkbox" value="c" />c </label>
            <label><input name="Fruit" type="checkbox" value="d" />d </label>
        </form>
    </div>
    <div>
        <form id="ilikeB">
            您朋友爱吃的水果？<br /><br />
            <label><input name="Fruit" type="checkbox" value="a" />a </label>
            <label><input name="Fruit" type="checkbox" value="b" />b </label>
            <label><input name="Fruit" type="checkbox" value="c" />c </label>
            <label><input name="Fruit" type="checkbox" value="d" />d </label>
        </form>
    </div>
    <button id="InterSet" type="button">check</button>
</div>

<script>
    $('div.toupiao button').click(function () {sendApiToupiao(this.innerText)});
    $("#BaomingButton").click(function () {let inputval = $('#BaomingName').val();if (inputval === "") {alert("啥都没写")} else {sendApiBaoming(inputval)}});
    $('#ChouJiangButton').click(function () {sendApiChoujiang()})
    $('#getYZM').click(function () {getYZM()});
    $('#checkYZM').click(function () {checkYZM()})
    $('#InterSet').click(function () {
        let u =[];let friend = [];
        $("#ilikeA input[name='Fruit']:checked").each(function(i){//把所有被选中的复选框的值存入数组
            u[i] =$(this).val();
        });
        $("#ilikeB input[name='Fruit']:checked").each(function(i){//把所有被选中的复选框的值存入数组
            friend[i] =$(this).val();
        });
        // if (u == [] || friend ==[]){alert("至少选一个哦")}
        console.log(u,friend)
        FindInter(u.join(','),friend.join(','))
    })
</script>

</body>
</html>